package cn.dgut.training.service.impl;

import cn.dgut.training.dto.AdDTO;
import cn.dgut.training.entity.activity.Carousel;
import cn.dgut.training.entity.activity.GroupBuying;
import cn.dgut.training.mapper.CarouselMapper;
import cn.dgut.training.service.ICarouselService;
import cn.dgut.training.vo.BaseVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class CarouselServiceImpl extends ServiceImpl<CarouselMapper, Carousel> implements ICarouselService {

    @Resource
    private CarouselMapper carouselMapper;

    public BaseVO listCouponByPage(AdDTO adDTO) {

        //构造分页
        IPage page = new Page();
        BeanUtils.copyProperties(adDTO, page);
        //获取条件查询构造器
        QueryWrapper queryWrapper = AdDTO.getWrapper(adDTO);

        IPage res = carouselMapper.selectPage(page, queryWrapper);

        BaseVO baseVO = new BaseVO(res);

        return baseVO;
    }

}
